<?php
namespace app\common\model;

class Category extends Model
{
    // 设置自动写入时间字段类型
    protected $autoWriteTimestamp = 'timestamp';

    // 状态列表
    const status_datalist = [
        0 => '关闭',
        1 => '开启',
    ];

    protected $searchOptions = [
        'name'   => ['like', '%%%s%%'],// 名称
        'title'  => ['like', '%%%s%%'],// 标题
        'status' => ['in'],// 状态
    ];

    /**
     * 文章关联
     * @return \think\model\relation\HasMany
     */
    public function article()
    {
        return $this->hasMany(Article::class);
    }

    /**
     * 软件关联
     * @return \think\model\relation\HasMany
     */
    public function software()
    {
        return $this->hasMany(Software::class);
    }
}